﻿using CacheTestApp.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CacheTestApp.Helper;
using Microsoft.Phone.Controls;
using System.Windows.Navigation;
using System.ComponentModel;

namespace CacheTestApp.ViewModels
{
    public class MainViewModel : NotifyPropertyViewModel
    {
        #region Fields

        private ObservableCollection<HoneyEntity> _items = new ObservableCollection<HoneyEntity>();
        private string _tokenTag = "page1";

        #endregion

        #region Construtor

        public MainViewModel()
        {
            if (DesignerProperties.IsInDesignTool)
            {
                InitData();
            }
        }

        #endregion

        #region Properties

        public ObservableCollection<HoneyEntity> Items
        {
            get { return _items; }
            set { SetProperty(ref _items, value, () => this.Items); }
        }

        #endregion

        private async void InitData()
        {
            await Task.Delay(3000);
            List<HoneyEntity> honeyList = new List<HoneyEntity>();
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19226571203_146x147.jpg", Name = "*14*D女装新款 特价回馈 韩版时尚宽松无敌百搭印花T恤 YQ229", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao18008710582_146x219.jpg", Name = "牛仔背带裙", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao24223692669_146x194.jpg", Name = "【板凳家】韩国 小胡子眼镜软绵绵中长款短袖T NT1179", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19956943916_146x146.jpg", Name = "韩版碎花茶叶罐 迷你小铁罐 浪漫田园风格牙签筒 印花铁盒收纳盒", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img3.geilicdn.com/taobao24202428926_146x219.jpg", Name = "日系真丝不料 坡跟 鱼嘴 金色绑带厚底 淑女 百搭 高跟凉鞋", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao19230319688_146x207.jpg", Name = "小秦家 春夏新款大码女装个性宽松字母狗头T恤卫衣棉卷袖韩版包邮", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao17538737644_146x146.jpg", Name = "巴黎巴黎 2013春装新款韩版女装性感露肩长款长袖T恤打底衫 11958", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao19430627174_146x221.jpg", Name = "大东北~后背复古花样 中国姑娘 雪纺背心-03A", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19961027136_146x219.jpg", Name = "休闲口袋 背带牛仔长裤 牛仔连体裤", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao18028774711_146x207.jpg", Name = "1cm2013春夏新品 浪漫清新波点雪纺衬衫 荷叶边唯美大波点衬衣女", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img1.geilicdn.com/taobao24140796737_146x219.jpg", Name = "【尖】主推韩国官网 甜美浪漫马卡龙色减龄字母T恤", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao24203268686_146x219.jpg", Name = "欧美风拼接方块尖头撞色平底彩色荧光色小单鞋", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao24289220719_146x146.jpg", Name = "精致刺绣钩花蕾丝雪纺泡泡袖系带蕾丝衫蕾丝上衣1932", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao24267304801_146x146.jpg", Name = "猴子家~韩版时尚刺绣豹头 铆钉口袋高腰系带显瘦百搭短裤 女&A36", TokenTag = "page1" });

            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19226571203_146x147.jpg", Name = "*14*D女装新款 特价回馈 韩版时尚宽松无敌百搭印花T恤 YQ229", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao18008710582_146x219.jpg", Name = "牛仔背带裙", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao24223692669_146x194.jpg", Name = "【板凳家】韩国 小胡子眼镜软绵绵中长款短袖T NT1179", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19956943916_146x146.jpg", Name = "韩版碎花茶叶罐 迷你小铁罐 浪漫田园风格牙签筒 印花铁盒收纳盒", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img3.geilicdn.com/taobao24202428926_146x219.jpg", Name = "日系真丝不料 坡跟 鱼嘴 金色绑带厚底 淑女 百搭 高跟凉鞋", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao19230319688_146x207.jpg", Name = "小秦家 春夏新款大码女装个性宽松字母狗头T恤卫衣棉卷袖韩版包邮", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao17538737644_146x146.jpg", Name = "巴黎巴黎 2013春装新款韩版女装性感露肩长款长袖T恤打底衫 11958", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao19430627174_146x221.jpg", Name = "大东北~后背复古花样 中国姑娘 雪纺背心-03A", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19961027136_146x219.jpg", Name = "休闲口袋 背带牛仔长裤 牛仔连体裤", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao18028774711_146x207.jpg", Name = "1cm2013春夏新品 浪漫清新波点雪纺衬衫 荷叶边唯美大波点衬衣女", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img1.geilicdn.com/taobao24140796737_146x219.jpg", Name = "【尖】主推韩国官网 甜美浪漫马卡龙色减龄字母T恤", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao24203268686_146x219.jpg", Name = "欧美风拼接方块尖头撞色平底彩色荧光色小单鞋", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao24289220719_146x146.jpg", Name = "精致刺绣钩花蕾丝雪纺泡泡袖系带蕾丝衫蕾丝上衣1932", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao24267304801_146x146.jpg", Name = "猴子家~韩版时尚刺绣豹头 铆钉口袋高腰系带显瘦百搭短裤 女&A36", TokenTag = "page1" });


            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19226571203_146x147.jpg", Name = "*14*D女装新款 特价回馈 韩版时尚宽松无敌百搭印花T恤 YQ229", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao18008710582_146x219.jpg", Name = "牛仔背带裙", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao24223692669_146x194.jpg", Name = "【板凳家】韩国 小胡子眼镜软绵绵中长款短袖T NT1179", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19956943916_146x146.jpg", Name = "韩版碎花茶叶罐 迷你小铁罐 浪漫田园风格牙签筒 印花铁盒收纳盒", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img3.geilicdn.com/taobao24202428926_146x219.jpg", Name = "日系真丝不料 坡跟 鱼嘴 金色绑带厚底 淑女 百搭 高跟凉鞋", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao19230319688_146x207.jpg", Name = "小秦家 春夏新款大码女装个性宽松字母狗头T恤卫衣棉卷袖韩版包邮", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao17538737644_146x146.jpg", Name = "巴黎巴黎 2013春装新款韩版女装性感露肩长款长袖T恤打底衫 11958", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img4.geilicdn.com/taobao19430627174_146x221.jpg", Name = "大东北~后背复古花样 中国姑娘 雪纺背心-03A", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao19961027136_146x219.jpg", Name = "休闲口袋 背带牛仔长裤 牛仔连体裤", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao18028774711_146x207.jpg", Name = "1cm2013春夏新品 浪漫清新波点雪纺衬衫 荷叶边唯美大波点衬衣女", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img1.geilicdn.com/taobao24140796737_146x219.jpg", Name = "【尖】主推韩国官网 甜美浪漫马卡龙色减龄字母T恤", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao24203268686_146x219.jpg", Name = "欧美风拼接方块尖头撞色平底彩色荧光色小单鞋", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img2.geilicdn.com/taobao24289220719_146x146.jpg", Name = "精致刺绣钩花蕾丝雪纺泡泡袖系带蕾丝衫蕾丝上衣1932", TokenTag = "page1" });
            honeyList.Add(new HoneyEntity { CacheUrl = "http://img0.geilicdn.com/taobao24267304801_146x146.jpg", Name = "猴子家~韩版时尚刺绣豹头 铆钉口袋高腰系带显瘦百搭短裤 女&A36", TokenTag = "page1" });


            honeyList.ToObservable(this.Items, _tokenTag);
        }

        public void OnNavigateTo(PhoneApplicationPage currentPage, NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                InitData();
            }
        }
    }
}
